class YouthNoteController < ApplicationController
	layout 'standard'
	
	def new
		@note = YouthNote.new
	end
	
	def create
		@note = YouthNote.new params[:youth_note]
		@note.signature = current_user.login

    @note.save
    if (@note.errors.empty?)
      redirect_to :controller => 'youth', :action => 'edit', :id => params[:youth_id]
    else
      flash_errors(@note)
      redirect_to :back
    end
	end

  def edit
    @youth_note = YouthNote.find(params[:id])
  end

  def update
    @youth_note = YouthNote.find(params[:id])        
    @youth_note.update_attributes(params[:youth_note])
    if (@youth_note.errors.empty?)
      redirect_to :controller => 'youth', :action => 'edit', :id => @youth_note.youth_id
    else
      flash_errors(@youth_note)
      redirect_to :back
    end


    
  end

  def delete
    @youth_note = YouthNote.find(params[:id])
    @youth_note.destroy
    flash_errors(@youth_note) unless @youth_note.errors.empty?

    redirect_to :controller => 'youth', :action => 'edit', :id => @youth_note.youth_id
  end

end
